<!--
 * @Author: @yzcheng
 * @Date: 2021-02-25 16:53:20
 * @Version: 1.0
 * @LastEditors: @yzcheng
 * @Description: 
 * @LastEditTime: 2021-05-20 14:51:39
-->
<template>
  <div class="define_aside">
    <div class="define_header">
      <i class="el-icon-menu"></i>{{ $t("flowDefine.form.flowType.title") }}
    </div>
    <div class="define_content">
      <el-tree
        :data="treeData"
        @node-click="changeFlowType"
        node-key="id"
        :props="defaultProps"
      >
      </el-tree>
    </div>
  </div>
</template>

<script>
import { mapActions, mapState } from "vuex";
export default {
  name: "define_aside",
  data() {
    return {
      defaultProps: {
        children: "children",
        label: "name",
      },
    };
  },
  mounted() {
    this.getFlowList();
  },
  computed: {
    ...mapState({
      treeData: (state) => state.flowClassifyStore.treeData,
    }),
    ...mapState("flowDefineStore", ["form", "pageNum", "pageSize"]),
  },
  methods: {
    async changeFlowType(item) {
      this.form.flowType = item.id;
      this.form.flowTypeName = item.name;
      const { pageSize, pageNum } = this;
      const rst = await this.getFlowDefineList({
        num: pageNum,
        size: pageSize,
      });
      this._info(rst, {
        success: [
          this.$t("flowTask.flowData", [
            this.$t("button.search"),
            this.$t("flowDefine.title"),
          ]),
        ],
        error: [this.$t("flowTask.flowData")],
      });
    },
    ...mapActions("flowClassifyStore", ["getFlowList"]),
    ...mapActions("flowDefineStore", ["getFlowDefineList"]),
  },
};
</script>

<style  lang='scss' scoped>
.define_aside {
  background: #fff;
  padding-right: 10px;
  margin-right: 10px;
  height: calc(100%);
  width: 250px;
  overflow: auto;
  .define_header {
    border-bottom: 1px solid #eee;
    height: 40px;
    width: 100%;
    line-height: 40px;
    & i {
      color: #3e70dd;
      padding: 0 5px;
    }
  }
  .define_content {
    height: calc(100% - 40px);
    overflow: auto;
  }
}
</style>